import { BaseWindow } from "../../../../component/window/BaseWindow";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Cache } from "../../../cache/Cache";
import { SArenaCrossBetPlayerInfos } from "../../../../../Message/Public/SArenaCrossBetPlayerInfos";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ArenaCrossBetCoinPanel } from "./ArenaCrossBetCoinPanel";
import { MuiEvent } from "../../../../../com/mui/events/MuiEvent";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { ArenaCrossBetGoldPanel } from "./ArenaCrossBetGoldPanel";
import { GTabBar } from "../../../../../com/mui/controls/GTabBar";
type int = number;
//class ArenaCrossBetWindow
    
    export  class ArenaCrossBetWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(500, 468);
            title = Language.getString(44303);
            titleHeight = 47;
            return;
        }

        public setPlayerData(arg1: int, arg2: int): void
        {
            if (arg1 > 0) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetTwoPlayerBetInfo, {"finalPosType": arg1, "finalPos": arg2}));
            }
            return;
        }

        public updateMoney(): void
        {
            this._coinBetPanel.updateCoinNum(Cache.instance.role.money.coin);
            if (this._goldBetPanel) 
            {
                this._goldBetPanel.updateCoinNum(Cache.instance.role.money.gold);
            }
            return;
        }

        public updateInfo(arg1: SArenaCrossBetPlayerInfos): void
        {
            this._info = arg1;
            this._coinBetPanel.updateInfo(this._info);
            if (this._goldBetPanel) 
            {
                this._goldBetPanel.updateInfo(this._info);
            }
            return;
        }

        public updateMyRewardNum(): void
        {
            this._coinBetPanel.updateMyRewardNum();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 58, 464, 346, this);
            ObjCreate.createBg(257, 5, 500, 3, this, ImagesConst.Line).rotation = 90;
            this._tabBar = ObjCreate.createGTabBar(16, 33, Language.getArray(44380), 63, 22, this, this.onTabBarChangeHandler);
            this._coinBetPanel = new ArenaCrossBetCoinPanel();
            this._coinBetPanel.x = 18;
            this._coinBetPanel.y = 58;
            this.addChild(this._coinBetPanel);
            return;
        }

        /* internal  */onTabBarChangeHandler(arg1: MuiEvent): void
        {
            var loc1=this._tabBar.selectedIndex;
            if (loc1 != 0) 
            {
                if (loc1 == 1) 
                {
                    DisplayUtil.removeMe(this._coinBetPanel);
                    if (!this._goldBetPanel) 
                    {
                        this._goldBetPanel = new ArenaCrossBetGoldPanel();
                        this._goldBetPanel.x = 18;
                        this._goldBetPanel.y = 58;
                    }
                    if (!this.contains(this._goldBetPanel)) 
                    {
                        this.addChild(this._goldBetPanel);
                    }
                    this._goldBetPanel.updateInfo(this._info);
                }
            }
            else 
            {
                DisplayUtil.removeMe(this._goldBetPanel);
                if (!this.contains(this._coinBetPanel)) 
                {
                    this.addChild(this._coinBetPanel);
                }
                this._coinBetPanel.updateInfo(this._info);
            }
            return;
        }

        public static hasInstance(): Boolean
        {
            return !(ArenaCrossBetWindow._instance == null);
        }

        public static get instance(): ArenaCrossBetWindow
        {
            if (!ArenaCrossBetWindow._instance) 
            {
                ArenaCrossBetWindow._instance = new ArenaCrossBetWindow();
            }
            return ArenaCrossBetWindow._instance;
        }

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_coinBetPanel: ArenaCrossBetCoinPanel;

        /* internal */ /* var */_goldBetPanel: ArenaCrossBetGoldPanel;

        /* internal */ /* var */_info: SArenaCrossBetPlayerInfos;

        /* internal */ static /* var */_instance: ArenaCrossBetWindow;
    }
